package com.hfy.admin.controller;

import com.hfy.admin.service.AdminService;
import com.hfy.model.dto.admin.CaptchaDto;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import result.Result;

/**
 * @ author 韩
 * time: 2024/7/22 9:50
 */

@RestController
@RequestMapping("/user")
@Tag(name = "管理员用户控制器" ,description = "主要是进行管理员的的各种操作，比如登录，注册，用户操控等操作")
public class AdminController {
//    @Autowired
//    private AdminService loginService;


    @Autowired
    private AdminService adminService;


    @PostMapping("/captcha/generate")
    @Operation(summary = "生成验证码",description = "生成该账户的最新验证码会覆盖掉旧的")
    @Parameters({@Parameter(name = "email",description = "邮箱")
    })
    public Result generateCaptcha(@RequestBody CaptchaDto dto) {
        return adminService.generateCaptcha(dto.getEmail());
    }

    @PostMapping("/captcha/verify")
    @Operation(summary = "校验验证码",description = "生成该账户的最新验证码会覆盖掉旧的")
    @Parameters({@Parameter(name = "email",description = "邮箱"),
            @Parameter(name = "captcha",description = "验证码")
    })
    public Result verifyCaptcha(@RequestBody CaptchaDto dto) {
        return adminService.verifyCaptcha(dto);
    }



}
